﻿
@{
    ViewBag.Title = "Carrier_audit";
}

<h2>待审核报价</h2>
<div style="width:100%">
    <table style="width:100%;text-align:center">
        <thead>
            <tr>
                <th>序号</th>
                <th>承运单位</th>
                <th>审核类型</th>
                <th>审核人</th>
                <th>审核状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody id="xuansg">
        </tbody>
    </table>
</div>


@section scripts
{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        get_sh_xx()
        function get_sh_xx() {
            $.ajax({
                url: '/Freight/Carrier_audit',
                type: 'GET',
                data: { "state": 1},
                success: function (data) {
                    createRow_VT(data)
                },
                error: function () {
                    alert('Request Error');
                }
            })
        }

        function createRow_VT(data) {
            $("#xuansg tr").remove()
            var index=1
            $.each(data, function (i, item) {
                $.ajax({
                    url: '/Freight/Carrier_audit',
                    type: 'GET',
                    data: { "state": 2, "name": item.sh_zhuantiao },
                    success: function (data2) {
                        var $tr =
                            $(`
                                <tr>
                                    <th>${index}</th>
                                    <th>${data2}</th>
                                    <th>${item.sh_lx}</th>
                                    <th>${item.sh_ren}</th>
                                    <th>${item.sh_zt}</th>
                                    <th style="display:none">${item.sh_zhuantiao}</th>
                                    <th><a href="#" id="shenhe_zhuangtiao">审核</a></th>
                                </tr>
                            `)
                        index++
                        $("#xuansg").append($tr)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
                
            })
        }

        $(document).on("click", "#shenhe_zhuangtiao", function (e) {
            var lx = $(e.target).parent().parent().children().eq(1).text()
            var id = $(e.target).parent().parent().children().eq(4).text()
            console.log(lx)
            if (lx == "承运商报价审核") {
                console.log(lx)
                window.location.href = "/Freight/Expense_audit?id=" + id;
            }
        })
    </script>
}